import { adminUserIds } from '@/config';
import api from '@/services/organization/department-management';

export type Department = DepartmentManagementApi.InfoResponse;

export const getAllList = async () => {
  const res = await api.getAllList<Department[]>();
  return res.data;
};
export const getAllSelectList = async (params: DepartmentManagementApi.SelectParams) => {
  const res = await api.getAllSelectList<Department[]>(params);
  return res.data;
};
/** 根据用户ID 判断请求列表接口 */
export const getSelectList = async (
  params: DepartmentManagementApi.SelectParams,
  userId: string = '',
) => {
  return adminUserIds.includes(userId) ? getAllList() : getAllSelectList(params);
};
export const create = async (params: DepartmentManagementApi.CreateParams) => {
  const data = await api.create(params);
  return data;
};
export const update = async (params: DepartmentManagementApi.UpdateParams) => {
  const data = await api.update(params);
  return data;
};
export const remove = async (params: DepartmentManagementApi.DeleteParams) => {
  const data = await api.remove(params);
  return data;
};
export default {
  getAllList,
  getAllSelectList,
  getSelectList,
  create,
  update,
  remove,
};
